var
	//stores info about animation queue, fires animations
	AnimationQueue = function() {

	};

AnimationQueue.prototype = {

	//stores first animation in queue
	first: null,

	//stores last animation in queue
	last: null,

	//stores count of animations in queue
	length: 0,

	//returns true, if there is no animation in queue
	isEmpty: function() {
		return this.length === 0;
	},

	//adds animation to queue
	add: function(animation) {
		if (!this.isEmpty()) {
			this.last.after = animation;
		} else {
			//queue is empty, so added animation is also first
			this.first = animation;
		}
		this.last = animation;

		this.length++;
	},

	//removes first animation from queue
	remove: function() {
		if (this.isEmpty()) { //if queue is empty, just return null
			return null;
		}

		var result = this.first;

		if (this.length === 1) {
			this.last = null;
			this.first = null;
		} else {
			this.first = this.first.after;
		}

		this.length--;

		return result;
	},

	//returns first animation in queue
	peek: function() {
		return this.first;
	},

	//returns queue as array
	get: function() {
		var anim = this.first,
			result = [ ];

		while (anim !== null) {
			result.push(anim);
			anim = anim.after;
		}

		return result;
	},

	//removes all animations except the first one
	removeWaiting: function() {
		if (this.length > 1) {
			this.last = this.first;
			this.length = 1;
			this.first.after = null;
		}
	},

	//removes all animations
	clear: function() {
		this.last = null;
		this.first = null;
		this.length = 0;
	}

};
